package cate.game.role.bag.spice;

import cate.common.table.item.spice.row.SpiceBaseRow;
import cate.common.table.item.spice.row.SpiceBreakAttrRow;
import cate.common.table.item.spice.row.SpiceLevelAttrRow;
import cate.game.attr.FightAttr;
import cate.game.play.support.PlayBuildContext;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.Data;

@NoteClass("星格数据")
@Data
public class SpiceVO {
    @NoteField("星格tid")
    public int tid;
    @NoteField("星格等级")
    public int level;
    @NoteField("是否突破")
    public boolean broken;

    @JsonIgnore
    public FightAttr getPowerAttr(PlayBuildContext ctx){
        FightAttr attr = new FightAttr();

        SpiceBaseRow row = ctx.spiceExcel().base.get(tid);
        if (row == null) {
            return attr;
        }
        // 属性兽魂的属性
        SpiceLevelAttrRow attrRow = ctx.spiceExcel().levelAttr.getAttrRow(tid, level);
        if(attrRow != null){
            attr.add(new FightAttr(attrRow.attrStr));
        } else {
            SpiceBreakAttrRow breakAttrRow = ctx.spiceExcel().breakAttr.getAttrRow(tid, level);
            if (breakAttrRow != null) {
                attr.add(new FightAttr(breakAttrRow.breakAttrStr));
            }
        }
        return attr;
    }
}
